package com.hh.front.controller;

import com.hh.common.page.CommonPage;
import com.hh.common.request.PageParamRequest;
import com.hh.common.response.CommonResult;
import com.hh.common.response.integral.IntegralOrderDetailInfoResponse;
import com.hh.common.response.integral.IntegralOrderDetailResponse;
import com.hh.service.service.integral.IntegralOrderService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController()
@RequestMapping("api/front/integral/order")
public class IntegralOrderController {

    @Autowired
    private IntegralOrderService integralOrderService;

    /**
     * 订单列表
     * @param type
     * @param keyword
     * @param pageRequest
     * @return
     */
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type", value = "1=待发货,2=待收货,3=待评价,4=已完成", required = true)
    })
    public CommonResult<CommonPage<IntegralOrderDetailResponse>> orderList(@RequestParam(name = "type") Integer type, String keyword,
                                                                           @ModelAttribute PageParamRequest pageRequest) {
        return CommonResult.success(integralOrderService.orderList(type, keyword, pageRequest));
    }

    /**
     * 订单详情
     * @param orderId 订单编号
     * @return 订单详情
     */
    @ApiOperation(value = "订单详情")
    @RequestMapping(value = "/detail/{orderId}", method = RequestMethod.GET)
    public CommonResult<IntegralOrderDetailInfoResponse> orderDetail(@PathVariable String orderId) {
        return CommonResult.success(integralOrderService.detailOrder(orderId));
    }

    /**
     * 确认收货
     * @param orderId
     * @return
     */
    @RequestMapping(value = "/take", method = RequestMethod.POST)
    public CommonResult<Boolean> take(@RequestParam(value = "orderId") String orderId) {
        return CommonResult.success(integralOrderService.take(orderId));
    }

    /**
     * 提醒发货
     * @param orderId
     * @return
     */
    @RequestMapping(value = "/remindSend", method = RequestMethod.POST)
    public CommonResult<Boolean> remindSend(@RequestParam(value = "orderId") String orderId) {
        return CommonResult.success("提醒成功");
    }
}
